# Entering the Data
mat <- as.matrix(read.table(text= "node	Mina_Salman	Larnaca_Port	Port_Alexandria	Port_Bandar_Abbas	Port_of_Umm_Qasr	Port_of_Haifa	Port_of_Aqaba	Port_of_Shuwaikh	Port_of_Beirut	Port_of_Salalah	Port_of_Gaza	Port_of_Doha	Port_of_King_Abdul_Aziz	Port_of_Jeddah	Port_of_Latakia	Port_of_Mersin	Port_of_Jebel_Ali	Port_of_Hodeidah
Mina_Salman	0	1779.914255	1788.337584	380	382	1177.322243	1233.045805	310	1239.525289	174.946068	3178	140	82.9373952	918.7908312	1385.961628	1595.896909	327	1222.678631
Larnaca_Port	1779.914255	0	426	2146.653049	1404.104183	180	653	1465.659281	138	2452	207	2030.022337	1759.179906	1080	275	253.5098115	2263.93171	1619
Port_Alexandria	1788.337584	426	0	2360.476021	1614.687413	370	548.2183421	1542.117192	427	2397	242	1914.039574	1763.067596	1024	571	546	2118.791268	1563
Port_of_Bandar_Abbas	380	2146.653049	2360.476021	0	581	1743.629144	1856.372166	537	1708.639931	943	2922	355	365	1892.657276	1766.307338	2011.879782	173	1776
Port_of_Umm_Qasr	382	1404.104183	1614.687413	581	0	1001.728226	1114.471248	71	966.7390128	1524	3383	490	274	1069.11486	1023.758472	1225.918373	606	1417.063151
Port_of_Haifa	1177.322243	180	370	1743.629144	1001.728226	0	362.0411685	982.9377228	81	2367	83	1404.752131	1150.756358	995	237	233	1639.309452	1534
Port_of_Aqaba	1233.045805	653	548.2183421	1856.372166	1114.471248	362.0411685	0	1037.365388	443.6286712	1943	486	1419.654944	1205.184024	571	601.5660937	765.2270604	1625.054587	1110
Port_of_Shuwaikh	310	1465.659281	1542.117192	537	71	982.9377228	1037.365388	0	1030.885904	1480	3363	421	203	992.6569488	1088.553312	1256.371948	562	618.4127521
Port_of_Beirut	1239.525289	138	427	1708.639931	966.7390128	81	443.6286712	1030.885904	0	2416	153	1470.842868	1216.199147	1044	185.4752295	191	1705.400189	1583
Port_of_Salalah	174.946068	2452	2397	943	1524	2367	1943	1480	2416	0	2086	1177.970191	1280.993987	1372	2582	2577	849.4603524	833
Port_of_Gaza	3178	207	242	2922	3383	83	486	3363	153	2086	0	3139	3203	828	248	316	2975	1275
Port_of_Doha	140	2030.022337	1914.039574	355	490	1404.752131	1419.654944	421	1470.842868	1177.970191	3139	0	219	1044.492821	1614.687413	1781.8581	187	1303.672181
Port_of_King_Abdul_Aziz	82.9373952	1759.179906	1763.067596	365	274	1150.756358	1205.184024	203	1216.199147	1280.993987	3203	219	0	894.168792	1354.860104	1536.285656	389	1188.337366
Port_of_Jeddah	918.7908312	1080	1024	1892.657276	1069.11486	995	571	992.6569488	1044	1372	828	1044.492821	894.168792	0	1209	1205	1231.10196	539
Port_of_Latakia	1385.961628	275	571	1766.307338	1023.758472	237	601.5660937	1088.553312	185.4752295	2582	248	1614.687413	1354.860104	1209	0	89	1851.188579	1748
Port_of_Mersin	1595.896909	253.5098115	546	2011.879782	1225.918373	233	765.2270604	1256.371948	191	2577	316	1781.8581	1536.285656	1205	89	0	2049.460789	1744
Port_of_Jebel_Ali	327	2263.93171	2118.791268	173	606	1639.309452	1625.054587	562	1705.400189	849.4603524	2975	187	389	1231.10196	1851.188579	2049.460789	0	1487.689526
Port_of_Hodeidah	1222.678631	1619	1563	1776	1417.063151	1534	1110	618.4127521	1583	833	1275	1303.672181	1188.337366	539	1748	1744	1487.689526	0
", header=T))

# prepare data for graph functions - set NA to zero to indicate no direct edge
nms <- mat[,1]
nms
mat <- mat[, -1]
mat
colnames(mat) <- rownames(mat) <- nms
rownames(mat)
colnames(mat)
mat[is.na(mat)] <- 0


# create graph from adjacency matrix
g <- graph.adjacency(mat, weighted=TRUE)


# Get all path distances
(s.paths <- shortest.paths(g, algorithm = "dijkstra"))

